home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / DSMODS / ICONS.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  5.6 KB  |  279 lines

  1. #include "osbind.h"
  2. #include "deskset2.h"
  3. #include "gemdefs.h"
  4. #include "alert.h"
  5.  
  6. #define BOOKW 0x0180
  7. #define BOOKH 0x002c
  8.  
  9. #define MAXPAGE 999
  10.  
  11. typedef    struct    mfdb
  12.     {
  13.     int    *data;
  14.     int    width;
  15.     int    height;
  16.     int    wwidth;
  17.     int    format;
  18.     int    planes;
  19.     int    res1;
  20.     int    res2;
  21.     int    res3;
  22.     }MFDB;
  23.  
  24. extern    int bookd[];
  25. extern     int bookm[];
  26.  
  27. extern  int shandle;
  28. extern  int sxres,syres;
  29. extern  int splane;
  30. extern  int curr_page;
  31. extern  int prev_handle;
  32. extern  int txt_handle;
  33. extern  char *get_lmem();
  34. extern  int tmplate_flag;
  35.  
  36. MFDB    mskmfdb;        /* Mask memory form definition block      */
  37. MFDB    objmfdb;        /* Object ......            */
  38. MFDB    scrmfdb;        /* Screen .... Data is always 0L    */
  39. MFDB    bufmfdb;
  40.  
  41.  
  42. int    color_index[2];            /* Used by vrt_cpyfm         */
  43. int     bltpxy[20];
  44. int     savepxy[8];
  45. int    restpxy[8];
  46.  
  47. int     xbook;
  48. int     ybook;
  49.  
  50. int     tmpxy[4];
  51.  
  52. int objw;
  53. int *bltbuffer;
  54. long buffsize;
  55.  
  56. int pageside;
  57.  
  58. set_icon_pos()
  59. {
  60.    objw =  (BOOKW)/6;
  61.    xbook = sxres - objw - 10;
  62.    ybook = syres - BOOKH - 5;
  63. }
  64.  
  65. icon_setup()
  66. {
  67.  
  68.    buffsize = 4000L * (long)splane;            /* For now */
  69.    bltbuffer = (int *)get_lmem(buffsize);    /* cjg  05-18-88 */
  70.    if(!bltbuffer)
  71.    {
  72.         alert_cntre(ALERT14);
  73.     close_work();            /* blow us away from DeskSET! */
  74.    }
  75.  
  76.    color_index[0] = 0;
  77.    color_index[1] = 1;
  78.    scrmfdb.data = 0L;
  79.  
  80.    savepxy[0] = xbook;
  81.    savepxy[1] = ybook;
  82.    savepxy[2] = savepxy[0] + objw - 1;
  83.    savepxy[3] = savepxy[1] + BOOKH - 1;
  84.    savepxy[4] = 0;
  85.    savepxy[5] = 0;
  86.    savepxy[6] = objw - 1;
  87.    savepxy[7] = BOOKH - 1;
  88.  
  89.    restpxy[0] = 0;
  90.    restpxy[1] = 0;
  91.    restpxy[2] = objw - 1;
  92.    restpxy[3] = BOOKH - 1;
  93.    restpxy[4] = xbook;
  94.    restpxy[5] = ybook;
  95.    restpxy[6] = restpxy[4] + objw - 1;
  96.    restpxy[7] = restpxy[5] + BOOKH - 1;
  97.  
  98.    bufmfdb.width = objw;
  99.    bufmfdb.height = BOOKH;
  100.    bufmfdb.wwidth = (objw + 15)/16;
  101.    bufmfdb.format = 0;
  102.    bufmfdb.planes = splane;
  103.  
  104.    objmfdb.width = BOOKW;
  105.    objmfdb.height = BOOKH;
  106.    objmfdb.wwidth = (BOOKW + 15) / 16;
  107.    objmfdb.format = 0;
  108.    objmfdb.planes    = 1;
  109.    
  110.    mskmfdb.width = BOOKW;
  111.    mskmfdb.height = BOOKH;
  112.    mskmfdb.wwidth = (BOOKW + 15) / 16;
  113.    mskmfdb.format = 0;
  114.    mskmfdb.planes    = 1;        
  115.  
  116.    objmfdb.data = bookd;        /* Set up data for mfdb         */
  117.    mskmfdb.data = bookm;
  118.    bufmfdb.data = bltbuffer;
  119.    vro_cpyfm(shandle,3,savepxy,&scrmfdb.data,&bufmfdb.data);    
  120. }
  121.  
  122.  
  123. page_bk_book()
  124. {
  125.    register int i,j;
  126.  
  127.    bltpxy[4] = xbook;
  128.    bltpxy[5] = ybook;
  129.    bltpxy[6] = bltpxy[4] + objw - 1;
  130.    bltpxy[7] = bltpxy[5] + BOOKH - 1;
  131.    objmfdb.data = bookd;        /* Set up data for mfdb         */
  132.    mskmfdb.data = bookm;
  133.    tmpxy[0] = 0;
  134.    tmpxy[1] = 0;
  135.    tmpxy[2] = tmpxy[0] + objw - 1;
  136.    tmpxy[3] = tmpxy[1] + BOOKH - 1;
  137.    for(i = 0;i < 6;i++)
  138.    {
  139.       draw_obj(tmpxy);
  140.       tmpxy[0] += objw;
  141.       tmpxy[2] += objw;
  142.       for(j = 0;j < 3000;j++);
  143.    }
  144.    tmpxy[0] = 0;
  145.    tmpxy[1] = 0;
  146.    tmpxy[2] = tmpxy[0] + objw - 1;
  147.    tmpxy[3] = tmpxy[1] + BOOKH - 1;
  148.    draw_obj(tmpxy);            /* Draw final open book  */
  149. }
  150.  
  151.  
  152. page_fd_book()
  153. {
  154.    register int i,j;
  155.  
  156.    bltpxy[4] = xbook;
  157.    bltpxy[5] = ybook;
  158.    bltpxy[6] = bltpxy[4] + objw - 1;
  159.    bltpxy[7] = bltpxy[5] + BOOKH - 1;
  160.    objmfdb.data = bookd;        /* Set up data for mfdb         */
  161.    mskmfdb.data = bookm;
  162.    tmpxy[0] = 5*objw;
  163.    tmpxy[1] = 0;
  164.    tmpxy[2] = tmpxy[0] + objw - 1;
  165.    tmpxy[3] = tmpxy[1] + BOOKH - 1;
  166.  
  167.    for(i = 0;i < 6;i++)
  168.    {
  169.       draw_obj(tmpxy);
  170.       tmpxy[0] -= objw;
  171.       tmpxy[2] -= objw;
  172.       for(j = 0;j < 3000;j++);
  173.    }
  174. }
  175.  
  176.  
  177. draw_obj(src)
  178. register int src[];
  179. {
  180.     bltpxy[0] = src[0];
  181.     bltpxy[1] = src[1];
  182.     bltpxy[2] = src[2];
  183.     bltpxy[3] = src[3];
  184.     Vsync();
  185.         vro_cpyfm(shandle,3,restpxy,&bufmfdb.data,&scrmfdb.data);    
  186.     vrt_cpyfm(shandle,2,bltpxy,&mskmfdb.data,&scrmfdb.data,
  187.         color_index);
  188.         color_index[0] = 1;
  189.     color_index[1] = 0;
  190.     vrt_cpyfm(shandle,2,bltpxy,&objmfdb.data,&scrmfdb.data,color_index);
  191.     color_index[0] = 0;
  192.     color_index[1] = 1;
  193. }
  194.  
  195. icon_clicked(mx,my)
  196. int mx,my;
  197. {
  198.    if(mx > xbook && mx < xbook + objw &&
  199.       my > ybook && my < ybook + BOOKH)
  200.     return(1);
  201.    else 
  202.     return(0);
  203. }
  204.  
  205. animate_icon(mx,direction)
  206. int mx;
  207. int *direction;
  208. {
  209.    int ret;
  210.    int x,y,w,h;
  211.  
  212.    wind_get(prev_handle,WF_CURRXYWH,&x,&y,&w,&h);
  213.    if(x + w >= xbook && y + h >= ybook)
  214.     return(0);
  215.    wind_get(txt_handle,WF_CURRXYWH,&x,&y,&w,&h);
  216.    if(x + w >= xbook && y + h >= ybook)
  217.     return(0);
  218.    ret = 1;
  219.    vs_clip(shandle,0,tmpxy);
  220.    gsx_moff();
  221.    if(mx > xbook + (objw/2))
  222.    {
  223.         if(tmplate_flag)
  224.         {
  225.           if(curr_page == -1)
  226.                 ret = 0;
  227.           else if(pageside == 0)
  228.           {
  229.             do_pagenum(curr_page+1,1);
  230.           }
  231.         }
  232.         else
  233.         {
  234.       if(curr_page == MAXPAGE)
  235.          ret = 0;
  236.       else if(pageside == 0)            /* Left side */
  237.       {
  238.         do_pagenum(curr_page+1,1);       /* Place text on right side */   
  239.           }
  240.       else 
  241.       {
  242.         page_fd_book();
  243.         do_pagenum(curr_page+1,0);
  244.       }
  245.         }
  246.         *direction = PNEXT;
  247.    }
  248.    else
  249.    {
  250.         if(tmplate_flag)
  251.         {
  252.           if(curr_page == -2)
  253.               ret = 0;
  254.           else if(pageside == 1)
  255.           {
  256.          do_pagenum(curr_page - 1,0);
  257.           }
  258.         }
  259.         else
  260.         {
  261.       if(curr_page == 0)
  262.          ret = 0;
  263.       else if(pageside == 1)
  264.       {
  265.          do_pagenum(curr_page - 1,0);
  266.           } 
  267.       else
  268.       {
  269.          page_bk_book();
  270.          do_pagenum(curr_page - 1,1);
  271.       }
  272.         }
  273.         *direction = PPREV;
  274.    }
  275.    gsx_mon();
  276.    screen_clip();
  277.    return(ret);
  278. }
  279.